<?php

/**
 * Yii Controller BookController
 *
 * @author nguyenmanhluu
 * @since Sep 17, 2013 - 5:54:16 PM
 */
class DefaultController extends FrontController
{

//    public $business = '';

    public function actionIndex()
    {
        if (!isset($_GET['biz']))
        {
            throw new CHttpException(404, 'Not found');
        }
        if (isset($_GET['t']) && trim($_GET['t'])!="")
            $page = trim($_GET['t']);
        else
            $page = "";
        if ($page=='embed')
        {
            $this->layout = "//layouts/mainembed";
            $this->render('eindex', array(
                'biz' => $this->biz
            ));
        }else
            $this->render('index', array(
                'biz' => $this->biz
            ));
    }

    public function actionGetMap()
    {
        $biz_id = $_POST['biz_id'];
        $biz = Users::model()->findByPk($biz_id);

        echo $this->renderPartial('_map', array(
            'business' => $biz,
            ), false, True);
    }
	
	public function actionClassList()
    {
        $classes = array();
        if (isset($_POST['get_classes']) && $_POST['get_classes'] == 'yes')
        {
            $classes = Room::model()->getClasses();
        }
        echo json_encode($classes);
        Yii::app()->end();
    }
    
    public function actionGetembed()
    {
        if (!Yii::app()->request->isAjaxRequest)
            $this->redirect($this->createUrl("/"));
        
        $width = isset($_POST['width'])?$_POST['width']:'100%';
        $height = isset($_POST['height'])?$_POST['height']:'500';
        $param = isset($_POST['param'])?$_POST['param']:'';
        $title = isset($_POST['title'])?$_POST['title']:'';
        $desc = isset($_POST['desc'])?$_POST['desc']:'';
        $scrolling = isset($_POST['scrolling'])?$_POST['scrolling']:'no';
        $url = isset($_POST['url'])?$_POST['url']:'';
        $this->renderPartial('_embed',array(
            'title' => $title,
            'desc' => $desc,
            'width'=>$width,
            'height'=>$height,
            'param' => $param,
            'url' => $url,
            'scrolling' => $scrolling,
        ),false,true);
        Yii::app()->end();
    }

}

/** 
 * End file BookController
 */
